package com.jboa.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.jboa.dao.IBizClaimVoucherDAO;
import com.jboa.dao.IDetailDAO;
import com.jboa.service.IBizClaimVoucherService;
import com.jboa.vo.BizClaimVoucher;
import com.jboa.vo.PageHelper;
@Service("voucherService")
public class BizClaimVoucherServiceImpl implements IBizClaimVoucherService {
	@Autowired
	@Qualifier("voucherDao")
	private IBizClaimVoucherDAO dao;
	@Autowired
	@Qualifier("detailDao")
	private IDetailDAO detaildao;
	/**
	 * 根据填报人id获取报销单信息
	 */
	public void getBypage(PageHelper page) {
		dao.getBypage(page);
	}
	
	/**
	 * 添加报销单
	 */
	public boolean add(BizClaimVoucher voucher) {
		dao.save(voucher);
		if(voucher.getId()!=null){
			return true;
		}
		return false;
		
	}

	/**
	 * 修改报销单
	 */
	public boolean update(BizClaimVoucher voucher) {
		try{
			//detaildao.deleteByVoucherId(voucher.getId());
			dao.update(voucher);
			System.out.println("成功");
			return true;
			
		}catch(Exception e){
			e.printStackTrace();
			System.out.println("修改出错了");
			return false;
		}
		
	}
	
	/**
	 * 获取报销单详情
	 */
	public BizClaimVoucher getDetailById(Long id) {
		return dao.getById(id);
	}
	
}
